package com.qianfeng.vhly.youshare.model;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created with IntelliJ IDEA.
 * User: vhly[FR]
 * Date: 15/2/6
 * Email: vhly@163.com
 */
public class Product {

    // TODO 成员变量
    /*

        "app_gname": "智能咖啡杯",
        "goods_name": "不锈钢智能感温咖啡杯",
        "type": "0",
        "url": "goods.php?id=134",
        "goods_img": "images\/no_picture.gif",
        "promote_price": "",
        "goods_brief": "外观与功能都无可挑剔",
        "shop_price": "￥98元",
        "market_price": "￥118元",
        "name": "不锈钢智能感温咖啡杯",
        "goods_id": "134",
        "goods_style_name": "不锈钢智能感温咖啡杯",
        "goods_thumb": "images\/201411\/thumb_img\/134_thumb_G_1414811942965.png",
        "add_time": "2014-10-17"

     */

    private String appGName; // "app_gname": "智能咖啡杯",
    private String goodsName; // "goods_name": "不锈钢智能感温咖啡杯",
    private String type; // "type": "0",
    private String url; // "url": "goods.php?id=134",
    private String goodsImg; // "goods_img": "images\/no_picture.gif",
    private String promotePrice; // "promote_price": "",
    private String goodsBrief; // "goods_brief": "外观与功能都无可挑剔",
    private String shopPrice; // "shop_price": "￥98元",
    private String marketPrice; // "market_price": "￥118元",
    private String name; // "name": "不锈钢智能感温咖啡杯",
    private String goodsId; // "goods_id": "134",
    private String goodsStyleName; // "goods_style_name": "不锈钢智能感温咖啡杯",
    private String goodsThumb; // "goods_thumb": "images\/201411\/thumb_img\/134_thumb_G_1414811942965.png",
    private String addTime; // "add_time": "2014-10-17"

    // TODO 解析

    /**
     * 解析JSON数据
     * @param json
     */
    public void parseJSON(JSONObject json) {
        if (json != null) {

            try {
                type = json.getString("type"); // 必须存在的字段优先解析，这样保证数据的有效性
                goodsImg = json.getString("goods_img");
                shopPrice = json.getString("shop_price");
                name = json.getString("name");
                goodsId = json.getString("goods_id");
                goodsThumb = json.getString("goods_thumb");

                goodsStyleName = json.optString("goods_style_name");
                addTime = json.optString("add_time");
                appGName = json.optString("app_gname");
                goodsName = json.optString("goods_name");
                url = json.optString("url");
                promotePrice = json.optString("promote_price");
                goodsBrief = json.optString("goods_brief");
                marketPrice = json.optString("market_price");
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }

    // Get/Set


    public String getAddTime() {
        return addTime;
    }

    public void setAddTime(String addTime) {
        this.addTime = addTime;
    }

    public String getAppGName() {
        return appGName;
    }

    public void setAppGName(String appGName) {
        this.appGName = appGName;
    }

    public String getGoodsBrief() {
        return goodsBrief;
    }

    public void setGoodsBrief(String goodsBrief) {
        this.goodsBrief = goodsBrief;
    }

    public String getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(String goodsId) {
        this.goodsId = goodsId;
    }

    public String getGoodsImg() {
        return goodsImg;
    }

    public void setGoodsImg(String goodsImg) {
        this.goodsImg = goodsImg;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsStyleName() {
        return goodsStyleName;
    }

    public void setGoodsStyleName(String goodsStyleName) {
        this.goodsStyleName = goodsStyleName;
    }

    public String getGoodsThumb() {
        return goodsThumb;
    }

    public void setGoodsThumb(String goodsThumb) {
        this.goodsThumb = goodsThumb;
    }

    public String getMarketPrice() {
        return marketPrice;
    }

    public void setMarketPrice(String marketPrice) {
        this.marketPrice = marketPrice;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPromotePrice() {
        return promotePrice;
    }

    public void setPromotePrice(String promotePrice) {
        this.promotePrice = promotePrice;
    }

    public String getShopPrice() {
        return shopPrice;
    }

    public void setShopPrice(String shopPrice) {
        this.shopPrice = shopPrice;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
}
